-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support package exports #6125
base: v-next
Are you sure you want to change the base?
Support package exports #6125
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
|
hardhatTotal size of the bundle: List of dependencies (sorted by size)
|
fd95d70
to
58f0de7
Compare
await fs.promises.access(packageJsonPath, fs.constants.R_OK); | ||
return await fs.promises.realpath(packageJsonPath); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should use the utils' fs
module
* @param packageName the name of the package to find | ||
* @returns the absolute real path (resolved symlinks) of the package.json | ||
*/ | ||
export async function findPackageJson( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should at at least one or two tests of this
@@ -1,3 +1,5 @@ | |||
import type { Exports } from "resolve.exports"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should duplicate this type to avoid re-exporting a dependency type
Note to self: Double check that this situation:
where
and throws that "foo/a.sol" doesn't exist, and not "foo/src/a.sol". |
This PR adds support for package.json#exports for packages that distribute solidity files.
Implementation details:
npm/[email protected]/Foo.sol
instead ofnpm/[email protected]/src/Foo.sol
, for an import of the kindimport 'mypkg/Foo.sol'
. This is arbitraryrequire.resolve
to manual lookup using the help ofrequire.resolve.paths
, to support packages that don't export their package.jsonresolve.exports
package. In this case we avoid usingrequire.resolve
because it may resolve to different packages in the filesystem for a given package name and version.Known issues:
mypkg/TheContract.sol
resolves tomypkg/src/TheContract.sol
. If user doesimport 'mypkg/thecontract.sol'
, I know that the correct resolved path issrc/TheContract.sol
, but I'm not sure how to it back toTheContract.sol
. Asking for suggestions on how to approach thisCloses #5992